package com.hzit.portail.controller;

import com.hzit.portail.dto.ContentDTO;
import com.hzit.portail.service.IPortalService;
import com.ruoyi.system.api.domain.Content;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * 类名：
 * 作者：WF
 * 功能：
 */
@Controller
@RequestMapping
public class PortalController {
	@Autowired
	private IPortalService portalService;
	//1. 默认欢迎页面
	@GetMapping({"/","/index.html"})
	public String index(Model model){
		//1.1 根据分类查询广告列表
		List<ContentDTO> contentList = portalService.findContentsByCategoryId(1L);
		//1.2 将查询出的结果放到model中
		model.addAttribute("contentList",contentList);
		return "index";         //真正的物理视图： /templates/index.html
	}
}
